package hongcaosp.app.android.user.settings.safety.update;

import android.content.Intent;
import android.graphics.Paint;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import hongcaosp.app.android.R;
import hongcaosp.app.android.user.settings.safety.update.iview.UpdateByPasswordIView;
import hongcaosp.app.android.user.settings.safety.update.presenter.UpdateByPasswordPresenter;
import xlj.lib.android.base.component.BaseFragment;

public class UpdateByPasswordFragment extends BaseFragment implements UpdateByPasswordIView {

    private EditText et_password_now;
    private TextView tv_updateByCode;

    private UpdateByPasswordPresenter presenter;

    @Override
    public void initView() {
        presenter = new UpdateByPasswordPresenter(this);

        findViewById(R.id.tv_update_by_code).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ((UpdatePasswordActivity)getActivity()).updateByCodeFragment();
            }
        });
        findViewById(R.id.btn_next).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                presenter.check(et_password_now.getText().toString().trim());
            }
        });
        et_password_now = findViewById(R.id.et_password_now);
        tv_updateByCode = findViewById(R.id.tv_update_by_code);

        tv_updateByCode.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
    }

    @Override
    public int getLayoutRes() {
        return R.layout.fragment_update_by_passowd;
    }

    @Override
    public void checkOver() {
        ((UpdatePasswordActivity)getActivity()).updatePasswordFragment();
    }
}
